home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac-Source 1994 July
/
Mac-Source_July_1994.iso
/
C and C++
/
Compilers⁄Interps
/
kevoSource
/
global.h
< prev
next >
Wrap
Text File
|
1993-05-13
|
7KB
|
269 lines
/* Kevo -- a prototype-based object-oriented language */
/* (c) Antero Taivalsaari 1991-1993 */
/* Some parts (c) Antero Taivalsaari 1986-1988 */
/* Global.h: Global definitions and data areas */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <signal.h>
#include <setjmp.h>
#include <time.h>
/* For portability (we want int's to be at least 32 bits long) */
/*
#define int long
#define unsigned unsigned long
*/
/* Include portable header files */
#include "memory.h"
#include "lists.h"
#include "context.h"
#include "family.h"
#include "recompile.h"
#include "tasks.h"
#include "files.h"
#include "keybuf.h"
#include "signals.h"
#include "debug.h"
#include "kernel.h"
#include "image.h"
#include "prim.h"
#include "blockfiles.h"
/* Global compile-time constants */
#undef TRUE
#undef FALSE
#define TRUE -1L
#define FALSE 0L
#define NIL 0L
/* CELL should be 'sizeof(int)' */
#define CELL 4
#define BS 8
#define TAB 9
#define LF 10
#define CR 13
#define BL 32
/* Root contexts (name spaces) */
/* 'rootContext' holds the names of all the system definitions */
/* 'userContext' is the root for user-given definitions */
/* 'lastContext' refers to the latest defined context in the system */
extern CONTEXT* rootContext;
extern CONTEXT* userContext;
extern CONTEXT* lastContext;
extern CONTEXT* dummyContext;
/* Name (pair) flags */
#define ImmedFlag 0x80
#define SmudgeFlag 0x40
#define HiddenFlag 0x08
/* References to the three execution stacks */
/* Note that in the current implementation stacks grow upwards so */
/* as to allow them to be resized at runtime simply using 'realloc' */
/* The amount of additional items at the bottom of each stack */
/* (reserved to avoid crashes resulting from stack manipulation errors */
#define UNDERFLOWRESERVE 4
/* Data stack */
extern int* dataSp;
#define topData (*dataSp)
#define secondData (*(dataSp-1))
#define thirdData (*(dataSp-2))
#define fourthData (*(dataSp-3))
/* Return stack */
extern int** returnSp;
#define topReturn (*returnSp)
#define secondReturn (*(returnSp-1))
#define thirdReturn (*(returnSp-2))
#define fourthReturn (*(returnSp-3))
/* Context stack */
extern int** contextSp;
#define topContext (*contextSp)
#define secondContext (*(contextSp-1))
#define prevContext (*(contextSp+1))
#define CWD (*(contextStackBottom()+1))
/* The most frequently called functions are "inlined" here */
#define popData() (*dataSp--)
#define nPopData(n) dataSp -= (n)
#define pushData(data) *++dataSp = (data)
#define nPushData(n) dataSp += (n)
#define popReturn() (*returnSp--)
#define nPopReturn(n) returnSp -= (n)
#define pushReturn(addr) *++returnSp = (addr)
#define nPushReturn(n) returnSp += (n)
#define popContext() (*contextSp--)
#define pushContext(addr) *++contextSp = (addr)
/* DATAOFFSET tells how many extra cells each instance has */
/* before their actual data area starts. In the current implementation, */
/* The first two cells contain the '(=context)' operation and the address */
/* to the context itself (the dictionary/name space) */
#define DATAOFFSET 2
/* Execution pointers */
extern TASK** up; /* Current task pointer */
extern OBJECT* op; /* Previous object pointer */
extern int** ip; /* Instruction pointer */
/* Environment buffers for 'setjmp' */
extern jmp_buf p_inner; /* Preemptive inner interpreter jump buffer for longjmp */
extern jmp_buf c_inner; /* Cooperative - " - */
extern jmp_buf debug; /* Debugger longjump buffer */
/* Multitasking modes and variables */
#define PREEMPTIVE 0
#define COOPERATIVE 1
extern int supervisor; /* Are we currently in the supervisor mode */
extern int multitasking; /* Is task switching allowed? */
extern int mtaskMode; /* Either PREEMPTIVE or COOPERATIVE */
extern int slice; /* Time slice counter */
extern int basePriority; /* Base priority of newly created tasks */
extern TASK** firstTask; /* The first defined task in the system */
extern TASK** latestTask; /* The latest defined task in the system */
extern int taskCount; /* How many tasks there are in total */
extern int runningCount; /* How many of them are running */
/* Critical region variables (see <| and |> in prim.c) */
extern int inProtRegion; /* Level of nested protected regions */
extern int mtStore; /* temporary store for 'multitasking' */
/* Tracing variables and states */
extern int traceMode; /* Current tracing mode */
#define NOTRACE 0
#define TRACE 1
#define FULLTRACE 2
#define QUITTRACE -1
/* Debugger variables */
/* Needed in 'debugExit' and 'resume' */
extern TASK** debugTask; /* The task which invoked debugging */
extern int** rpStore; /* Return stack pointer temporary store */
/* Macros to standard files */
/* Each task has its own file stacks, so these are pretty complicated */
#define infileStk ((int*)((*up)->infileStack->mfa))
#define infileSSize ((*up)->infileStack->sfa)
#define infileSp ((*up)->infilePtr)
#define infile ((*up)->infile)
#define outfileStk ((int*)((*up)->outfileStack->mfa))
#define outfileSSize ((*up)->outfileStack->sfa)
#define outfileSp ((*up)->outfilePtr)
#define outfile ((*up)->outfile)
#define errfile ((*up)->errfile)
extern FILE* confile; /* Console file */
extern FILE* imgfile; /* Image (boot) file */
/* String management buffer for several operations in 'port.c' */
#define CHARBUFLEN 256
extern char charbuffer[];
/* Propagation modes */
/* Needed in determining how widely dynamic changes should be propagated */
#define THIS_ONLY 1
#define WHOLE_FAMILY 2
#define DERIVATIVES 3
/* Modification modes */
/* Needed in clone family migration */
#define ADDING_SOMETHING 1
#define RENAMING_SOMETHING 2
#define REDEFINING_SOMETHING 3
#define REMOVING_SOMETHING 4
#define PASTING_SOMETHING 5
#define ENCAPSULATING_SOMETHING 6
/* Global references to certain primitives */
/* Initialized in 'prim.c' */
extern OBJECT* oExit;
extern OBJECT* oLit;
extern OBJECT* oStrLit;
extern OBJECT* oContext;
extern OBJECT* oSharedVar;
extern OBJECT* oTaskVar;
extern OBJECT* oSharedConst;
extern OBJECT* oTaskConst;
extern OBJECT* oREF;
extern OBJECT* oVAR;
extern OBJECT* oCONST;
/* Initialized in 'image.c' */
extern OBJECT* oBoot;
extern OBJECT* oShell;
extern OBJECT* oError;
extern OBJECT* oUserRoot;
/* Object kinds in object-oriented programming (needed mainly for the browser) */
#define UNKNOWN 1
#define PRIMITIVE 2
#define REF 3
#define VAR 4
#define CONST 5
#define METHOD 6